<?php
// +----------------------------------------------------------------------
// | sfadmin - Suifeng Administration
// +----------------------------------------------------------------------
// | Copyright (c) 2017-2020 http://suifeng.tech All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: suifeng <1787585212@qq.com>
// +----------------------------------------------------------------------

use app\common\framework\admin\AdminForm;
use app\common\framework\admin\AdminTable;
use app\common\framework\admin\AdminToolbar;

function sf_admin_form_render($array, $errors, $options)
{
    return (new AdminForm($array, $errors))->renderForm($options);
}

function sf_admin_form_group($array, $errors, $field, $label, $help, $control, $options = array())
{
    return (new AdminForm($array, $errors))->renderGroup($field, $label, $help, $control, $options);
}

function sf_admin_form_control($array, $errors, $field, $label, $help, $control, $options = array())
{
    return (new AdminForm($array, $errors))->renderControl($field, $label, $help, $control, $options);
}

function sf_admin_form_text($array, $errors, $field, $options = array())
{
    return (new AdminForm($array, $errors))->renderText($field, $options);
}

function sf_admin_form_switch($array, $errors, $field, $options = array())
{
    return (new AdminForm($array, $errors))->renderSwitch($field, $options);
}

function sf_admin_form_label($label)
{
    return (new AdminForm(null, null))->renderLabel($label);
}

function sf_admin_form_help($help)
{
    return (new AdminForm(null, null))->renderHelp($help);
}

function sf_admin_form_error($error)
{
    return (new AdminForm(null, null))->renderError($error);
}

function sf_admin_form_button($text, $icon, $class, $options = array())
{
    return (new AdminForm(null, null))->renderButton($text, $icon, $class, $options);
}

function sf_admin_form_submit_and_cancel($submit_url, $cancel_url)
{
    return (new AdminForm(null, null))->renderSubmitAndCancel($submit_url, $cancel_url);
}

function sf_admin_table_render($array, $options = array())
{
    return (new AdminTable($array))->renderTable($options);
}

function sf_admin_table_header_select($options = array())
{
    return (new AdminTable(null))->renderHeaderSelect($options);
}

function sf_admin_table_header_text($text, $options = array())
{
    return (new AdminTable(null))->renderHeaderText($text, $options);
}

function sf_admin_table_column_text($row, $field, $options = array())
{
    return (new AdminTable(null))->renderColumnText($row, $field, $options);
}

function sf_admin_table_column_select($row, $field, $options = array())
{
    return (new AdminTable(null))->renderColumnSelect($row, $field, $options);
}

function sf_admin_table_action($text, $icon, $class, $options = array())
{
    return (new AdminTable(null))->renderAction($text, $icon, $class, $options);
}


function sf_html_toolbar_button($text, $icon, $class, $options = array())
{
    return (new AdminToolbar())->renderButton($text, $icon, $class, $options);
}

